package com.yunc.modules.shop.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunc.base.controller.CommonController;
import com.yunc.common.utils.R;
import com.yunc.modules.shop.entity.Order;
import com.yunc.modules.shop.entity.dto.OrderDTO;
import com.yunc.modules.shop.service.IOrderService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单管理
 *
 * @author congcong tao
 * @date 2018/12/24 9:15
 */
@RestController
@RequestMapping("order")
public class OrderController extends CommonController {

    private static final Logger logger = LogManager.getLogger(OrderController.class);

    @Autowired
    private IOrderService orderService;

    @GetMapping("/page")
    public R page(Page<OrderDTO> page, Order order){
        orderService.pageInfo(page, order);
        return R.ok().put("data", page.getRecords()).put("count", page.getTotal());
    }

    @GetMapping("/info/{orderId}")
    public R info(@PathVariable String orderId){
        Order order = orderService.getById(orderId);
        return R.ok().put("order", order);
    }
}
